package com.schoolai.schoolset.controller;

import com.schoolai.entity.SchoolAiDietaryRequirements;
import com.schoolai.entity.SchoolSetClassInfo;
import com.schoolai.entity.SchoolSetNews;
import com.schoolai.schoolset.service.ISchoolAiDietaryRequirementsService;
import com.schoolai.util.base.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

/**
 * Copyright(C),2019-2025，XX公司
 * FileName:SchoolAiDietaryRequirementsController
 * Author:bobby
 * 创建时间：2025/9/25 14:30
 * Description:餐饮要求表
 * History:
 * <auth>        <time>       <version>       <desc>
 * 作者          修改时间       版本号         描述
 */
@Slf4j
@Tag(name = "学生午餐要求条款", description = "餐饮要求条款")
@RestController
@RequestMapping("/DietaryRequirements")
public class SchoolAiDietaryRequirementsController {
    @Autowired
    ISchoolAiDietaryRequirementsService iSchoolAiDietaryRequirementsService;
    @Operation(summary = "未分页获取所有学生午餐要求条款")
    @GetMapping
    Result list(){
        List<SchoolAiDietaryRequirements> SchoolAiDietaryRequirementsList = iSchoolAiDietaryRequirementsService.list();
        if (SchoolAiDietaryRequirementsList==null||SchoolAiDietaryRequirementsList.size()==0){
            return Result.ok("无学生午餐要求");
        }
        return Result.ok(SchoolAiDietaryRequirementsList);
    }
    @Operation(summary = "通过id获取午餐要求")
    @GetMapping("/{id}")
    public Result view(@PathVariable("id") String id) {
        return Result.ok(iSchoolAiDietaryRequirementsService.getById(id));
    }

    @Operation(summary = "新增午餐要求")
    @PostMapping
    public Result save(@RequestBody SchoolAiDietaryRequirements schoolAiDietaryRequirements){
        return Result.ok(iSchoolAiDietaryRequirementsService.saveOrUpdate(schoolAiDietaryRequirements));
    }
    @Operation(summary = "修改午餐要求")
    @PutMapping
    Result update(@RequestBody SchoolAiDietaryRequirements schoolAiDietaryRequirements){
        return Result.ok(iSchoolAiDietaryRequirementsService.updateById(schoolAiDietaryRequirements));
    }
    @Operation(summary = "删除午餐要求")
    @DeleteMapping("/{id}")
    Result delete(@PathVariable("id") String id){
        SchoolAiDietaryRequirements schoolAiDietaryRequirements = iSchoolAiDietaryRequirementsService.getById(id);
        if(schoolAiDietaryRequirements == null) {
            return Result.error("操作失败！删除信息不存在！");
        }
        return Result.ok(iSchoolAiDietaryRequirementsService.removeById(id));
    }

}
